package com.itheima.stream;

import javax.lang.model.element.NestingKind;
import java.util.ArrayList;
import java.util.List;
import java.util.function.Consumer;

/*
终结方法  foreach
 */
public class Demo06 {

    public static void main(String[] args) {
        ArrayList<String> list = new ArrayList<>(List.of("坤坤", "签签", "滔滔", "鹿鹿", "小绵羊"));
      /*  ArrayList<String> newList = new ArrayList<>();
        list.stream().filter(s->s.length()==2).forEach(new Consumer<String>() {
            @Override
            public void accept(String s) {
                newList.add(s);
            }
        });
        list.stream().forEach(s-> System.out.println(s));*/
        long count = list.stream().filter(s -> s.charAt(0) == s.charAt(1)).count();
        System.out.println(count);


    }


}
